package com.uenpay.im.ui.old.activity.bankcard;

import com.qiyunxin.android.http.utils.StringUtils;
import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 验证银行卡
 * 
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class CheckBankCardInvokeItem extends BaseHttpInvokeItem {
	public class CheckBankCardInvokeItemResult extends HttpInvokeResult {
	}

	public CheckBankCardInvokeItemResult getOutPut() {
		return (CheckBankCardInvokeItemResult) GetResultObject();
	}

	public CheckBankCardInvokeItem(String bankcard, String accountname) {
		String url = APIConfiguration.getBaseUrl()
				+ "Purse/Purse/checkBankCard?bankcard="
				+ StringUtils.encodeParams(bankcard) + "&accountname="
				+ accountname + "&" + APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		CheckBankCardInvokeItemResult result = new CheckBankCardInvokeItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}

		return result;
	}

}
